package src.main.java.org.lambda;

public class LambdaTest1 {
    public static void main(String[] args) {
        //匿名内部类
        /*Animal a = new Animal(){
            @Override
            public void run() {
                System.out.println("狗跑的快！！");
            }
        };*/

        //lambda表达式不是能简化全部匿名内部类的写法，只能简化函数式接口的匿名内部类（函数式接口：有且只有一个抽象方法的接口）
        //错误的代码
        /*       Animal a = () ->{
            System.out.println("狗跑的快");
        }
        a.run();*/

       /* Swimming s = new Swimming(){
            @Override
            public void swim() {
                System.out.println("快乐的有用--");
            }
        };*/
        Swimming s =()->{
            System.out.println("快乐的游泳");
        };
        s.swim();
    }
}

interface Swimming{
    void swim();
}
abstract class Animal{
    public abstract void run();
}